<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center authentication_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub authentication_fd0_0'>
				<view class='flex flex-wrap align-center'>
					<person></person>
				</view>
				<view class='flex flex-wrap align-stretch justify-center flex-sub'>
					<text class='authentication_fd0_0_c1_c0'>我的认证</text>
				</view>
				<view class='flex flex-wrap align-center authentication_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		
		<view style="padding: 8rpx 0;margin: 0 32rpx;">
			<back></back>
		</view>
		
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#6A0002"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		
		<template v-else>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout authentication_flex_1">
				<view class="content_info">
					<!-- <text class='authentication_fd1_0' v-show="zhuangtai==-1">上传护照</text>
					<text class='authentication_fd1_0' v-show="zhuangtai==1">认证成功</text>
					<text class='authentication_fd1_0' v-show="zhuangtai==0">上传护照(审核中)</text>
					<text class='authentication_fd1_0' v-show="zhuangtai==2">上传护照(审核失败，请重新上传)</text>
					<text class='authentication_fd1_0' v-show="zhuangtai==2">失败原因:{{reason}}</text> -->
					<view class='flex flex-wrap align-center'>
						<view class="upload_content" v-if="zhuangtai==-1 || zhuangtai == 2">
							<view class="no_authen">
								<view class="no_authen_1">
									<image :src="STATIC_URL+'116.png'" mode="aspectFill"></image>
									<text v-if="zhuangtai == -1">您还没有实人认证</text>
									<text v-if="zhuangtai == 2">认证失败</text>
								</view>
								<view class="no_authen_2" v-if="zhuangtai == -1">请上传护照首页，进行认证~</view>
								<view class="no_authen_3" v-if="zhuangtai == 2">失败原因:{{reason}}</view>
							</view>
							<view class="upload position-relative" >
								<text v-if="fd1_1_c0 != ''" @tap="fd1_1_c0 = ''"
									class='fu-iconfont2 position-absolute authentication_fd1_1_c0_icon'>&#xE8E7;</text>
								<image class=" authentication_fd1_1_c0_image" mode="aspectFill"
									@tap="soloChooseImage('img','fd1_1_c0',false,false)"
									:src="fd1_1_c0 ? fd1_1_c0 : STATIC_URL+'3.png'">
								</image>
							</view>
						</view>
						<view class="upload_content" v-if="zhuangtai==1">
							<view class="upload_1 position-relative" >
								<image class=" authentication_fd1_1_c0_image_1" mode="aspectFill"
									:src="STATIC_URL+'49.png'">
								</image>
							</view>
							<view class="button_1">已认证</view>
						</view>
						<view class="upload_content" v-if="zhuangtai==0">
							<view class="upload_1 position-relative" >
								<image class=" authentication_fd1_1_c0_image_1" mode="aspectFill"
									:src="STATIC_URL+'50.png'">
								</image>
							</view>
							<view class="button_1">认证中</view>
						</view>
					</view>
				</view>
			</view>
			
			<!---flex布局flex布局结束-->
			<view class="flex benben-position-layout flex flex-wrap align-center authentication_flex_2"
				v-show="abutton==true">
				<button class='authentication_fd2_0' @tap.stop="submitToFunc">提交认证</button>
			
			</view>
		</template>
		
		<view :style="{height: '88rpx'}"></view>

	</view>
</template>
<script>
	import UploadImage from '@/common/utils/upload-image.js'
	import back from "@/components/back/index.vue"
	import person from "@/components/person/index.vue"
	import {
		validate
	} from '@/common/utils/validate.js'
	import {
		locale
	} from '../../../libs/day';
	export default {
		components: {
			back,
			person
		},


		data() {
			return {
				"fd1_1_c0": "",
				"img": "",
				abutton: '',
				zhuangtai: -1,
				reason: '',
				isShow: true,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getshiming()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//上传单图、多图方法
			soloChooseImage(id, path, obj, obj1, fnName = false) {
				let self = this
				if (!obj) obj = this
				if (!obj1) obj1 = this
				if (self.uploading) {
					return
				}
				// 从相册中选择图片
				uni.chooseImage({
					count: 1, // 默认3
					sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
					success: function(res) {
						self.uploading = true
						// 开始上传
						new UploadImage(res.tempFiles, {
							complete: function(res) {
								self.uploading = false
								if (id) self.$set(obj, id, res[0].id)
								if (path) self.$set(obj1, path, res[0].path)
								if (fnName) self[fnName]()
							},
						})
					},
				})
			},
			async getshiming() {
				let res = await this.$api.post(global.apiUrls.isshiming, {});
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.isShow = false;
				// console.log(res.data.data.certify_status, 'res.data.data.certify_status')
				if (res.data.data.certify_status == 1) {
					this.abutton = false
					this.zhuangtai = 1
				} else if (res.data.data.certify_status == 0) {
					this.abutton = false
					this.zhuangtai = 0
				} else if (res.data.data.certify_status == 2) {
					this.abutton = true
					this.zhuangtai = 2
				} else if (res.data.data.certify_status == -1) {
					this.abutton = true
					this.zhuangtai = -1
				}
				
				this.fd1_1_c0 = res.data.data.certify_image
				this.reason = res.data.data.certify_reason
			},
			//提交
			async submitToFunc() {
				if (!validate(this.fd1_1_c0, 'require')) {
					this.$message.info('请上传图片');
					return false;
				}
				let res = await this.$api.post(global.apiUrls.renzheng, {
					certify_image: this.fd1_1_c0
				});
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.$message.info('上传成功')
				setTimeout(() => {
					this.getshiming()
				}, 800)

				// this.$urouter.navigateBack(1);
			}
		}
	};
</script>
<style lang="scss" scoped>
	.bg_2 {
		width: 100%;
		height: 338rpx;
		background: url(/static/images/115.png) no-repeat;
		background-size: 100% 100%;
		position: absolute;
		top: 10rpx;
		left: 0;
		z-index: 2;
	}
	.content_info {
		padding: 0 30rpx 0;
		position: absolute;
		top: 69rpx;
		z-index: 5;
	}
	.upload_content {
		width: 690rpx;
		height: 552rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		opacity: 1;
		border: 1rpx solid #EEEEEE;
		.no_authen {
			padding: 50rpx 0 0;
			text-align: center;
			.no_authen_1 {
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 32rpx;
				font-weight: bold;
				image {
					width: 30rpx;
					height: 30rpx;
					margin-right: 20rpx;
				}
			}
			.no_authen_2 {
				font-size: 24rpx;
				color: #999;
				margin: 32rpx 0 64rpx;
			}
			.no_authen_3 {
				font-size: 24rpx;
				color: #8B060D;
				margin: 32rpx 0 64rpx;
			}
		}
		.upload {
			width: 420rpx;
			height: 260rpx;
			margin: 0 auto;
		}
		.upload_1 {
			width: 250rpx;
			height: 180rpx;
			margin: 114rpx auto 96rpx;
		}
		.button_1 {
			width: 502rpx;
			height: 88rpx;
			background: #FAE5E6;
			border-radius: 44rpx;
			color: #8B060D;
			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			line-height: 88rpx;
			margin: 0 auto;
		}
	}
	
	
	
	
	
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor0);
		background-size: 100% auto !important;
	}

	.authentication_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.authentication_fd0_0_c2 {
		width: 32rpx;
		height: 32rpx;
	}

	.authentication_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.authentication_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.authentication_fd0_0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.authentication_flex_1 {
		// padding: 32rpx 32rpx 0rpx 32rpx;
		width: 100%;
		height: 338rpx;
		background: url(/static/images/125.png) no-repeat;
		background-size: 100% 100%;
		position: relative;
	}

	.authentication_fd1_1_c0_image {
		width: 420rpx;
		height: 260rpx;
		margin: 0 auto;
		border-radius: 16rpx;
	}
	.authentication_fd1_1_c0_image_1 {
		width: 250rpx;
		height: 180rpx;
		margin: 0 auto;
	}

	.authentication_fd1_1_c0_icon {
		top: 0rpx;
		right: 0rpx;
		z-index: 10;
		color: #ff5536;
	}

	.authentication_fd1_0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 500;
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.authentication_flex_2 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(65rpx + var(--window-bottom));
	}

	.authentication_fd2_0 {
		background: #6A0002;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin: 0rpx auto 0rpx auto;
	}
</style>